﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL.admin
{
    public partial class Search : System.Web.UI.Page
    {
        Classes cl = new Classes();
        student stud = new student();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Panel1.Visible = false; Panel2.Visible = false;
                DataTable dt = cl.GetRecords(-99, "", -99, false, " and ");
                ddclasses.DataSource = dt;
                ddclasses.DataTextField = "class_name";
                ddclasses.DataValueField = "class_id";
                ddclasses.DataBind();
                ddcls.DataSource = dt;
                ddcls.DataTextField = "class_name";
                ddcls.DataValueField = "class_id";
                ddcls.DataBind();
                
            }
        }

        //protected void btnsearch_Click(object sender, EventArgs e)
        //{
        //    string sname = tbname.Text;
        //        DataTable dt = stud.GetRecords(-99, "", -99,Convert.ToInt64(ddclasses.SelectedValue.ToString()), "", "%" + sname + "%", "", "", "", "", -99, -99, "", -99, "", "", "","",false, " and ");
        //        GridView1.DataSource = dt;
        //        GridView1.DataBind();
        //        //GridView2.Visible = false;
        //        //GridView1.Visible = true;
        //    //}
        //    //if (sname == "")
        //    //{
        //    //    DataTable dt1 = stud.GetRecords(-99, "", Convert.ToInt64(tbrollno.Text),-99, "", "", "", "", "", "", -99, -99, "", -99, "", "", false, " and ");
        //    //    GridView2.DataSource = dt1;
        //    //    GridView2.DataBind();
        //    //    GridView2.Visible = true;
        //    //    GridView1.Visible = false;
        //    //}
        //    //if (ddclasses.SelectedValue != null)
        //    //{
        //    //    DataTable dt1 = stud.GetRecords(-99, "", -99, Convert.ToInt64(ddclasses.SelectedValue.ToString()), "", "", "", "", "", "", -99, -99, "", -99, "", "", false, " and ");
        //    //    GridView2.DataSource = dt1;
        //    //    GridView2.DataBind();
        //    //    GridView2.Visible = true;
        //    //    GridView1.Visible = false;

        //    //}
        //}

        protected void lbtnname_Click(object sender, EventArgs e)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
        }

        protected void lbtnrollno_Click(object sender, EventArgs e)
        {
            Panel2.Visible = true;
            Panel1.Visible = false;
        }

        protected void btnsrch1_Click(object sender, EventArgs e)
        {
            DataTable dt1 = stud.GetRecords(-99, "", Convert.ToInt64(tbrollno.Text),Convert.ToInt64(ddcls.SelectedValue.ToString()), "", "", "", "", "", "", -99, -99, "", -99, "", "","","", false, " and ");
            GridView1.DataSource = dt1;
            GridView1.DataBind();
            //GridView2.Visible = true;
            //GridView1.Visible = false;
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void btnsearch_Click1(object sender, EventArgs e)
        {
            string sname = tbname.Text;
            DataTable dt = stud.GetRecords(-99, "", -99, Convert.ToInt64(ddclasses.SelectedValue.ToString()), "", "%" + sname + "%", "", "", "", "", -99, -99, "", -99, "", "", "", "", false, " and ");
            GridView1.DataSource = dt;
            GridView1.DataBind();
            //GridView2.Visible = false;
            //GridView1.Visible = true;
            //}
            //if (sname == "")
            //{
            //    DataTable dt1 = stud.GetRecords(-99, "", Convert.ToInt64(tbrollno.Text),-99, "", "", "", "", "", "", -99, -99, "", -99, "", "", false, " and ");
            //    GridView2.DataSource = dt1;
            //    GridView2.DataBind();
            //    GridView2.Visible = true;
            //    GridView1.Visible = false;
            //}
            //if (ddclasses.SelectedValue != null)
            //{
            //    DataTable dt1 = stud.GetRecords(-99, "", -99, Convert.ToInt64(ddclasses.SelectedValue.ToString()), "", "", "", "", "", "", -99, -99, "", -99, "", "", false, " and ");
            //    GridView2.DataSource = dt1;
            //    GridView2.DataBind();
            //    GridView2.Visible = true;
            //    GridView1.Visible = false;

            //}
        }
    }
}
